<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/4 0004
 * Time: 17:48
 */
namespace app\wap\controller;
use think\Db;


class brand extends Base
{
    public function index($id=0){
//        session('style_id',null);
        if($id==0){
            session('style_id',$id);
//                $id= input('param.id');
            $id=Db::name('aosclass')->where(['show'=>2,'class_id'=>$id])->find();
            $where=[
                'z.is_del'=>0,
                'z.is_show'=>1,
                'z.sign'=>"mobile",
                'j.class_id'=>$id['class_id']
            ];
            $data_zp = Db::name('aos')->alias('z')
                ->join('aosclass j','z.class_id=j.class_id')
                ->where($where)
                ->order('z.sort desc,z.id desc')
                ->field('z.title,z.id,z.main_img,z.click,z.content,z.create_time,z.is_recom,j.class_id,j.name as jname')
                ->find();
        }else{
            session('style_id',$id);
//                $id= input('param.id');
            $id=Db::name('aosclass')->where(['show'=>2,'class_id'=>$id])->find();
            $where=[
                'z.is_del'=>0,
                'z.is_show'=>1,
                'z.sign'=>"mobile",
                'j.class_id'=>$id['class_id']
            ];
            $data_zp = Db::name('aos')->alias('z')
                ->join('aosclass j','z.class_id=j.class_id')
                ->where($where)
                ->order('z.sort desc,z.id desc')
                ->field('z.title,z.id,z.main_img,z.click,z.content,z.create_time,z.is_recom,j.class_id,j.name as jname')
                ->find();
        }

        $data_style = Db::name('aosclass')->where('show',2)->select();
//        var_dump($data_style);die;
        $this->assign('data_style',$data_style);
        $this->assign('data_zp',$data_zp);
        $this->assign('data_seo', getColumnseo(6));
        return $this->fetch();

    }
    public  function details($id=0){
        if($id==1){
            session('style_id',1);
            $where=[
                'z.is_del'=>0,
                'z.is_show'=>1,
                'z.sign'=>"mobile",
                'j.show'=>2
            ];
            $data_de = Db::name('psjd')->alias('z')
                ->join('psjdclass j','z.class_id=j.class_id')
                ->where($where)
                ->order('z.sort desc,z.id desc')
                ->field('z.title,z.id,z.main_img,z.click,z.content,z.create_time,z.is_recom,j.class_id,j.name as jname')
                ->select();
            $this->assign('data_de',$data_de);
        }elseif($id==2){
            session('style_id',2);
            $where=[
                'z.is_del'=>0,
                'z.is_show'=>1,
                'z.sign'=>"mobile",
                'j.show'=>2
            ];
            $data_v = Db::name('video')->alias('z')
                ->join('vclass j','z.class_id=j.class_id')
                ->where($where)
                ->order('z.sort desc,z.id desc')
//                ->field('z.title,z.id,z.main_img,z.click,z.content,z.create_time,z.is_recom,j.class_id,j.name as jname')
                ->select();
            $this->assign('data_v',$data_v);
        }elseif($id>2){
            session('style_id',1);
            $where=[
                'z.is_del'=>0,
                'z.is_show'=>1,
                'z.id'=>$id,
                'z.sign'=>"mobile",
                'j.show'=>2
            ];

            $data_content = Db::name('psjd')->alias('z')
                ->join('psjdclass j','z.class_id=j.class_id')
                ->where($where)
                ->order('z.sort desc,z.id desc')
                ->field('z.title,z.id,z.main_img,z.click,z.content,z.create_time,z.is_recom,j.class_id,j.name as jname')
                ->find();

            $this->assign('data_content',$data_content);
        }


        $data_style = Db::name('aosclass')->where('show',2)->select();
        $this->assign('data_style',$data_style);
       $this->assign('data_seo', getColumnseo(7));
        return $this->fetch();
    }


    public  function vcr(){

        $type = intval(input('param.type'));
        $where ='is_show=1 and sign="mobile" and is_del = 0';
        if($type){
            $where .=' and type = '.$type;
            $this->assign('type',$type);
        }else{
            $this->assign(1,$type);
        }
        //
        $data_vcr = Db::name('vcr')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_vcr',$data_vcr);
	$this->assign('data_seo', getColumnseo(8));
        return $this->fetch();
    }


}